/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package jfinance.UI;

import java.security.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JPanel;
import jfinance.Transaction;

/**
 *
 * @author efim
 */
public class TransactionBeanForm extends JPanel {

    /**
     * Creates new form TransactionBeanForm
     */
    public TransactionBeanForm(Transaction transaction) {
        super(true);
        initComponents();
        ratioLabel.setText(transaction.getName());
        double amount = transaction.calculateAmount(0.0);
        valueLabel.setText(amount+"");
        if(amount>0){
            ratioLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("mini_icons/heart_green.png")));
        }else{
            ratioLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("mini_icons/heart_red.png")));
        }
        curLabel.setText(transaction.getCurrencySymbol());
        Date date = new Date(transaction.getDate());
        SimpleDateFormat ft = new SimpleDateFormat ("dd.MM.yyyy");
        dateLabel.setText(ft.format(date));
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        ratioLabel = new javax.swing.JLabel();
        valueLabel = new javax.swing.JLabel();
        curLabel = new javax.swing.JLabel();
        dateLabel = new javax.swing.JLabel();

        setRequestFocusEnabled(false);
        setVerifyInputWhenFocusTarget(false);
        java.awt.FlowLayout flowLayout1 = new java.awt.FlowLayout();
        flowLayout1.setAlignOnBaseline(true);
        setLayout(flowLayout1);

        jPanel1.setRequestFocusEnabled(false);
        jPanel1.setVerifyInputWhenFocusTarget(false);

        ratioLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jfinance/UI/mini_icons/heart_green.png"))); // NOI18N
        ratioLabel.setText("Transaction name");

        valueLabel.setText("1000.00");

        curLabel.setText("Руб");

        dateLabel.setText("12.04.1998");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(ratioLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(dateLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 74, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(valueLabel)
                .addGap(3, 3, 3)
                .addComponent(curLabel)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(valueLabel)
                    .addComponent(curLabel)
                    .addComponent(dateLabel)
                    .addComponent(ratioLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        add(jPanel1);
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel curLabel;
    private javax.swing.JLabel dateLabel;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel ratioLabel;
    private javax.swing.JLabel valueLabel;
    // End of variables declaration//GEN-END:variables
}
